package com.yt.generator;

import com.yt.model.MainTemplateConfig;
import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;

public class MainGenerator {

    public static void doGenerator(MainTemplateConfig mainTemplateConfig) throws IOException, TemplateException {
        String projectPath = System.getProperty("user.dir");

        String inputPath = projectPath + File.separator + "code-gen-backend/code-gen-demo-projects/acm-template";
        String outputPath = projectPath;

        StaticGenerator.copyFiles(inputPath, outputPath);

        // 动态生成
        String dynamicInputPath = projectPath + File.separator + "code-gen-basic" +
                File.separator + "src/main/resources/template/MainTemplate.java.ftl";
        String dynamicOutputPath = projectPath + File.separator +
                "acm-template/src/com/yt/acm/MainTemplate.java";

//        mainTemplateConfig.setAuthor("YTBaiduren");
//        mainTemplateConfig.setOutputText("结果：");
//        mainTemplateConfig.setLoop(true);
        DynamicGenerator.doGenerate(dynamicInputPath, dynamicOutputPath, mainTemplateConfig);
    }

}